<?php

include_once dirname(__FILE__) . '/../system/settings.php';
if ($_POST) {
    $id = $_POST['id'];
    $name = $_POST['name'];
    $id_type = $_POST['id_type'];

    if (!empty($id)) {
        if (!DetalhesControl::Update($name, $id_type, $id)) {
            header("location: " . $_POST['redirect']);
            exit();
        }
    } else {
        if (!DetalhesControl::Insert($name, $id_type)) {
            header("location: " . $_POST['redirect']);
            exit();
        }
    }
    header("location: " . $_POST['redirect']);
} else if ($_GET) {
    $id = $_GET['id'];
    if (!empty($id)) {
        DetalhesControl::Delete($id);
    }
    header("location: " . $_GET['redirect']);
}
?>
